package io.mvvm.ws.chain;

import io.mvvm.ws.entity.RequestInfo;
import io.mvvm.ws.entity.ResponseInfo;
import io.mvvm.ws.enumerate.MessageTypeEnum;
import io.netty.channel.ChannelHandlerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @program: Netty
 * @description: 订阅消息处理
 * @author: 潘
 * @create: 2021-04-28 19:45
 **/
@Component
public final class SubscribeMessageHandler extends MessageHandler {

    private static Logger logger = LoggerFactory.getLogger(SubscribeMessageHandler.class);

    @Override
    protected boolean isMatched(RequestInfo request) {
        return MessageTypeEnum.SUBSCRIBE.getAction().equals(request.getAction());
    }

    @Override
    protected ResponseInfo handler(RequestInfo request, ChannelHandlerContext ctx) {

        logger.info("执行订阅消息处理器...");

        ResponseInfo response = new ResponseInfo();
        response.setAction("SubscribeMessageHandler");
        response.setParams(null);
        return response;
    }
}
